﻿<%@ Page Trace="false" Language="C#"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>Digitizing</title>
    
    <meta http-equiv="content-style-type" content="text/css">
    <link href="../../styles/globalStyles.css" rel="stylesheet" type="text/css">
    <link href="../../styles/alphastyles.css" rel="stylesheet" type="text/css">
    <link href="../../viewerfiles/viewer.css" rel="stylesheet" type="text/css">   
    
    <meta http-equiv="content-script-type" content="text/javascript">
    
         
    <script  language="javascript" type="text/javascript">
      
      function DigitizePoint() {
          ShowResults("");
          parent.parent.mapFrame.DigitizePoint(OnPointDigitized);
      }
      function OnPointDigitized(point) {
          ShowResults("X: " + point.X + ", Y: " + point.Y);
      }
      function DigitizeLine() {
          ShowResults("");
          parent.parent.mapFrame.DigitizeLine(OnLineDigitized);
      }
      function OnLineDigitized(line) {
          ShowResults(FormatLineResults(line));
      }
      function DigitizeMultiLine() {
          ShowResults("");
          parent.parent.mapFrame.DigitizeMultiLine(OnMultiLineDigitized);
      }     
      function DigitizeLineString() {
          ShowResults("");
          parent.parent.mapFrame.DigitizeLineString(OnDigitizeLineString);
      }
      function OnDigitizeLineString(line) {
          ShowResults(FormatLineResults(line));
      }
          
      function DigitizeCircle() {
          ShowResults("");
          parent.parent.mapFrame.DigitizeCircle(OnCircleDigitized);
      }
      function OnCircleDigitized(circle) {
          ShowResults("Center X: " + circle.Center.X + ", Y: " + circle.Center.Y + "\nRadius: " + circle.Radius);
      }
      function DigitizeRectangle() {
          ShowResults("");
          parent.parent.mapFrame.DigitizeRectangle(OnRectangleDigitized);
      }
      function OnRectangleDigitized(rect) {
          str = "X1: " + rect.Point1.X + ", Y1: " + rect.Point1.Y + "\n";
          str += "X2: " + rect.Point2.X + ", Y1: " + rect.Point2.Y + "\n";
          
          ShowResults(str);
      }
      function DigitizePolygon() {
          ShowResults("");
          parent.parent.mapFrame.DigitizePolygon(OnPolygonDigitized);
      }
      function OnPolygonDigitized(poly) {
        ShowResults(FormatLineResults(poly));
        var geomText = poly.Count;
        for (var i = 0; i < poly.Count; i++)
        {
            geomText += "," + poly.Point(i).X + "," + poly.Point(i).Y;
        }
        parent.parent.frames['scriptFrame'].navigate('CreateGeometry.aspx?SESSION=<%=Request["SESSION"]%>&MAPNAME=<%=Request["MAPNAME"]%>&GEOMTEXT=' + geomText);
        
        
          
      }
      
        function OnClearSpatialFilter()
        {
            parent.parent.frames['scriptFrame'].navigate('CreateGeometry.aspx?SESSION=<%=Request["SESSION"]%>&MAPNAME=<%=Request["MAPNAME"]%>&COMMAND=ClearGeom');
        }	
      
      function FormatLineResults(line) {
          str = "נקודות: " + (line.Count - 1) + "\n";
          var area = 0;
          
          for(var i = 0; i < line.Count; i++) {
              pt = line.Point(i);
              str += "X" + i + ": " + pt.X + "\n Y" + i + ": " + pt.Y + "\n";
          }
          for(var i = 0; i < line.Count-1; i++) {
              pt = line.Point(i);
              area += pt.X * line.Point(i+1).Y - pt.Y * line.Point(i+1).X;
          }
          
          if(area<0)
            area*=-1;
           
          var str1 = new String(area/2);
                
          return 'שטח: '+str1.substr(0,str1.indexOf('.')+3)+" מ''ר\n"+str ;
      }
      function ShowResults(res)  {
          document.getElementById("res").value = res;
      }
      
    </script>
  </head>
  <body dir=rtl class="AppFrame" onload="DigitizePolygon()">   
    <h1 class="AppHeading">מדידת שטח</h1>
    <hr width=100%/> 
    <P class="InfoText">
        למדידה, סמנ/י שטח למדידה במפה באמצעות העכבר. ולסיום העזר/י במקש Ctrl במקלדת
    </p>
    תוצאה:<br>
    <textarea dir=rtl id="res" rows="10" cols="32" name="results">
    </textarea>
    
    <hr width=100%/> 
    <!--<input type="button" value=" Point " onclick="DigitizePoint();">
    <br>
    <input type="button" value=" LineString " onclick="DigitizeLineString();">    
    <br>-->
    <br />
    <input type="button" value="נסה שוב" onclick="DigitizePolygon();" style="width:auto">
    <input type="button" value="נקה מפה" onclick="OnClearSpatialFilter();" style="width:auto">
    <hr>
    
    <!--<p>Click button then drag on map: 
    </p>
    <input type="button" value=" Line " onclick="DigitizeLine();">
    <br>
    <input type="button" value=" Rectangle " onclick="DigitizeRectangle();">
    <br>
    <input type="button" value=" Circle " onclick="DigitizeCircle();">-->
    
      
  </body>
</html>